package com.manageserver.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.managecommon.result.PageResult;
import com.managecommon.result.Result;
import com.managepojo.dto.UserDTO;
import com.managepojo.dto.UserLoginDTO;
import com.managepojo.dto.UserPageQueryDTO;
import com.managepojo.entity.User;
import com.manageserver.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author linye
 * @Since 1.0.0
 * @Data 2023/7/13
 */
@RestController
@Api(tags = "用户接口")
@RequestMapping("/user")
@Slf4j
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public Result login(UserLoginDTO userLoginDTO){
        return Result.success();
    }

    @PostMapping("/register")
    public Result register() {
        return Result.success();
    }

    /**
     * 用户分页查询
     * @param userPageQueryDTO
     * @return total, records
     */
    @PostMapping("/page")
    @ApiOperation("用户分页查询")
    public Result<PageResult> page(@RequestBody UserPageQueryDTO userPageQueryDTO){
        log.info("用户分页查询: {}", userPageQueryDTO);
        PageResult pageResult = userService.pageQuery(userPageQueryDTO);
        return Result.success(pageResult);
    }
}
